this.name                                = "Orisis_shipScript";
this.author                                = "Thargoid";
this.copyright                        = "Creative Commons: attribution, non-commercial, sharealike.";
this.description                        = "Adds lifepods when energy gets low";
this.version                        = "1.0";

this.shipEnergyIsLow = function()
        {
        if(!this.shipEvacuated)
                {
                this.shipEvacuated = true;
                var leftPods = Math.ceil(Math.random() * 10) + 5;
                var rightPods = Math.ceil(Math.random() * 10) + 5;
                this.ship.commsMessage("Mayday, mayday! Hull breach imminent, all passengers and non-essential crew to the lifepods!");

                var offset;
                for(var i=0; i < rightPods; i++)
                        {
                        offset = new Vector3D([240, 0, Math.random() * 670 - 483]);
                        var orientation = this.ship.orientation;
                        orientation.w = -orientation.w;
                        system.legacy_addShipsAtPrecisely("escape-capsule", 1, "abs", this.ship.position.add(offset.rotateBy(orientation)));
                        }

                for(var i=0; i < leftPods; i++)
                        {
                        offset = new Vector3D([-240, 0, Math.random() * 670 - 483]);
                        var orientation = this.ship.orientation;
                        orientation.w = -orientation.w;
                        system.legacy_addShipsAtPrecisely("escape-capsule", 1, "abs", this.ship.position.add(offset.rotateBy(orientation)));
                        }
                }
        }

this.shipEnergyBecameFull = function()
        {
        this.shipEvacuated = false;
        }